package com.nave.princesslife.baseboard.functionality;

import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.nave.princesslife.R;
import com.nave.princesslife.main.ItemsBought;

public class Room_PetAdapter extends BaseAdapter {
	
	private Context context;
	private List<Pet_Base> clothes;
	
	public Room_PetAdapter(Context context, List<Pet_Base> cb) {
		this.context = context;
		this.clothes = cb;
	}
	
	@Override
	public int getCount() {
		return clothes.size();
	}

	@Override
	public Object getItem(int arg0) {
		return clothes.get(arg0);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		Pet_Base pa = clothes.get(position);
		LayoutInflater inflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View v = inflater.inflate(R.layout.activity_pet, null);

		TextView clothesName = (TextView) v.findViewById(R.id.room_pet_name);
		ImageView iv = (ImageView) v.findViewById(R.id.room_pet_image);

		clothesName.setText(pa.getName());
		iv.setImageResource(pa.getImage());
		
		//Se for o pet atual, deixar o background verde.
		if (pa.getBitmap() == ItemsBought.getInstance().getCurrentPet())
			v.setBackgroundColor(Color.rgb(72, 255, 0));

		return v;
	}
}
